steps360=400.0
degperstep=360.0 / steps360
TIMERPERIOD=1.0e-7
tregmin=65535*16
totaltime=1.0
#vi = degperstep / (TIMERPERIOD * tregmin)
vi=180
vf=1440.0
ef=10 # shape of the sigmoid, larger ef makes it sharper
accel=360.0 
amax=((vf-vi) * ef) / (4*totaltime)
ttotal=(ef*(vf-vi))/(4*accel)


set macros
NOYTICS = "set format y ''; unset ylabel"
YTICS = "set format y '%1.1f'; set ylabel ''"

lv(t, vf)=vi + ((vf-vi)*(t/totaltime))
lvd(t, vf)=vf + ((vi-vf)*(1 - t/totaltime))
sv(t, vf) = vi + (vf - vi) * (1 / (1+exp(-(((ef/totaltime)*t-(ef/2))))))
svd(t) = vf + (vi - vf) * (1 / (1+exp(-((ef - ((ef/totaltime)*t)) - (ef/2)))))

# Steps
ls(t, vf)=vi*t + ((vf-vi)*((t*t)/(2*totaltime)))
ss(t, vf)=vi*t + (vf-vi)*(totaltime/ef)*log(1+exp((((ef/totaltime)*t-(ef/2)))))
# Period in timer unit
lp(t, vf)=(degperstep*1e7) / lv(t, vf) 
sp(t, vf)=(degperstep*1e7) / sv(t, vf) 

#splot [t=0:totaltime] [vf=360:1440]  lp(t, vf)

svf(t,vf) = vi + (vf - vi) * (1 / (1+exp(-(((4*accel/(vf-vi))*t-(ef/2))))))
ssf(t,vf)=floor((steps360/360) * (vi*t + (vf-vi)*((vf-vi)/(4*accel))*log(1+exp((((4*accel/(vf-vi))*t-(ef/2)))))))
spf(t,vf)=(degperstep) / svf(t,vf)

#set parametric
#splot [t=0:totaltime] [vf=360:1440] ls(t,vf),vf, lp(t,vf)
#splot [t=0:totaltime] [vf=360:1440] ss(t,vf),vf, sp(t,vf)
#splot [t=0:ttotal] [vf=360:720] ssf(t,vf),vf, spf(t,vf)
splot  [t=0:ttotal] [vf=360:1440] (4*accel/(vf-vi))*t-(ef/2)
#unset parametric